<?php
session_save_path(realpath('../tmp/sessions/')); session_start();
include_once('../config/config.php'); include_once('../config/admin.ini.php');
include_once('../config/db.php'); include_once('../inc/function.php'); include_once('../config/pics.php');
function __autoload($class_name){require_once '../class/' . $class_name . '.class.php';}
$db = new db(); $admin = new admin(); $admin -> permissions();
if (@$_GET['Action'] == 'Exit'){
	$admin -> ExitPage = './'; 
	$admin -> logout();
}
if ($WebLangKind > 100){$WebLangKind = 100;} 
if ($WebLangKind < 1){$WebLangKind = 1;}
$Lang = @$_GET['Lang'];
if (!is_numeric($Lang) || $Lang < 1){ $Lang = 1; } 
if ($Lang > $WebLangKind) {MsgBox (1,'您提交的语言版本参数设置有误！','-1');}
$WebLangKind > 1 ? $OnWebLangName = '(' . $WebLangName[$Lang-1] . ')'  : $OnWebLangName = ''; 
function TopLang($Para=''){
	global $WebLangKind,$WebLangName,$Lang;
	if ($WebLangKind==1){return false;} 
	echo '<table border="0" cellspacing="0" cellpadding="0"><tr class="Notodd">' . "\n";
	for ($i=1;$i<=$WebLangKind;$i++){
		if ($Lang != $i) {
			echo '<td class="toplang"><a href="?' . $Para . 'Lang=' . $i . '">' . $WebLangName[$i-1] . '</a></td>';
		} else {
			echo '<td class="ontoplang">' . $WebLangName[$i-1] . '</td>';
		}
		echo '<td width="3"></td>' . "\n";
	}
	echo '</tr></table>' . "\n";
}
if($WebClearAllCache==1 || $_GET['Action']=='ClearAllCache' || $_GET['Action']=='ClearCompiledTpl'){
	include_once('../tools/smarty/Smarty.class.php');
	if (function_exists('__autoload')) {spl_autoload_register('__autoload');} 
	$SC = new SC();
	if (@$_GET['Action']!='ClearCompiledTpl'){
		$SC -> cache_dir  = '../tmp/cache';
		$SC -> cache -> clearAll(); 
		if (@$_GET['Action']=='ClearAllCache'){
			AdminLog(3,1,'清除所有缓存文件，结果：操作成功！');
			MsgBox(1,'缓存文件已全部清空。','-1');
		}
	} else {
		$SC -> compile_dir = "../tmp/translation";
		$SC -> utility -> clearCompiledTemplate();
		AdminLog(3,1,'清除所有模板编译文件，结果：操作成功！');
		MsgBox(1,'已清除所有的模板编译文件。','-1');
	}
}
function picstreatment($type,$field){
	global $_FILES,$upURL1,$upURL2,$ps;
	$up = new upload();
	$up->save_dir = '../uploadfile/';
	$up->ispics = true;
	$up->save_dir .= $type==0 ? 'Pages/' : ($type==1 ? 'Products/' : 'News/');	
	if($type != 1){
		if(empty($_FILES["$field"]['tmp_name'])) return true;
		$up->field_name = $field;
		if($up->perform()){
			$upURL1 = $up->URL;
		} else {
			return $up->info;
		}
	} else {
		$field = explode(',',$field);
		$up->is_del_tmp = false;
		if($ps['cut']['common']) $field[0] = $field[1];
		if(!empty($_FILES["$field[0]"]['tmp_name'])){
			$up->field_name	= $field[0];
			if($up->perform()){
				$upURL1 = $up->URL;
			} else {
				return $up->info;
			}	
		}
		if(!empty($_FILES["$field[1]"]['tmp_name'])){
			$up->field_name	= $field[1];
			$up->save_dir = '../uploadfile/Products/';
			$up->new_filename = 'Auto';
			if($up->perform()){
				$upURL2 = $up->URL;
			} else {
				return $up->info;
			}	
		}
	}
	$upURL1 = str_replace('../','',$upURL1);
	$upURL2 = str_replace('../','',$upURL2);	
	return true;
	unset($pic_save_dir,$up);
}
?>